#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int arr[100];
	int flag = 0;
	for (int i = 0;; i++)
	{
		scanf("%d", &arr[i]);
		if (arr[i] == 0)
		{
			break;
		}
		flag++;
	}
	for (int i= flag-1;i>=0;i--)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}